package com.sz.app.edi.service.order;

import com.sz.app.edi.service.order.impl.CusOrderServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

import javax.xml.ws.Endpoint;


//@Configuration
public class CxfConfig {
    @Autowired
    private Bus bus;

    @Bean
    public CusOrderService commonService() {
        return new CusOrderServiceImpl();
    }
    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }
    @Bean
    public ServletRegistrationBean dispatcherServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/services/*");
    }

    @Bean()
    public Endpoint endpoint1() {
        EndpointImpl endpoint = new EndpointImpl(bus, commonService());
        endpoint.publish("/CusOrderService");
        return endpoint;
    }
}